var express = require('express')
var proxy = require('http-proxy-middleware')
var history = require('connect-history-api-fallback')
var compression = require('compression')
var app = express()
app.use(compression())
app.use(
  '/api', proxy({
    target: 'http://106.13.1.45:8089',
    changeOrigin: true,
    pathRewrite: {
      '^/api': ''
    }
  })
)
app.use(
  history({
    index: './index.html'
  })
)
app.use(express.static('./dist'))
var port = 8999
// 生产环境的端口号
module.exports = app.listen(port, function (err) {
  if (err) {
    console.log(err)
    return
  }
  console.log('Listening at http://localhost:' + port + '\n')
})
